package com.itheima.reggie.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 当前我们要实现的分页查询功能,而在MybatisPlus 中就要用到分页插件,
 * 要使用分页插件,就要在配置类中声明分页插件的Bean对象
 */
//配置MP的分页插件 interceptor 是拦截器的意思
@Configuration
public class MybatisPlusConfig {
    @Bean //将返回值作为Bean对象交给Spring 处理
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        return mybatisPlusInterceptor;
    }

}
